<?php
class data_browser_info extends data {
	public function __construct() {
		parent::__construct();
	}
	public function save ($uid, $param_array) {
		$uid = intval($uid);
		if (is_array($param_array)) {
			$param_array = serialize($param_array);
		} else $param_array = '';
		
		return $this->db->execute("
			insert into
				browser_info
			set
				uid		= '".$uid."',
				param	= '".$param_array."',
				dt		= '".date('Y-m-d H:i:s')."'
		");
	}
	public function ls ($page=1, $limit=20) {
		$page	= ($page > 1) ? intval($page) : 1; // 默认为1
		$limit		= ($limit > 0) ? intval($limit) : 0;
		
		$execute = $this->db->execute('
			select 
				* 
			from 
				browser_info
			where
				1
			order by
				id DESC
			' . (($limit) ? ' limit ' . (($page - 1) * $limit) . ', ' . $limit . ' ' : '') . '
		');
		if (is_array($execute)) {
			foreach ($execute as $k=>$v) {
				$tmp = unserialize($v['param']);
				if (is_array($tmp)) {
					$param = array();
					foreach ($tmp as $k1=>$v1) {
						$param[] = array('k'=>$k1, 'v'=>$v1);
					}
					$execute[$k]['param'] = $param;
				} else 	$execute[$k]['param'] = '';
			}
			return $execute;
		} else return false;
	}
}
?>
